﻿Public Class clsXjPgd
    Public Function getXjPgd(workshop_id As Integer, startTime As String, endTime As String, chk As String) As DataTable
        Dim szSql As String = ""
        szSql &= "SELECT a.*,b.jp_layer_num,b.mould_no,b.prod_spec_name,c.type,c.spec,c.model FROM sf.b_pgd_mes a "
        szSql &= " left join sf.t_prod_spec b on a.support_model = b.prod_spec_id "
        szSql &= " left join sf.t_mst_jp c on a.type_value = c.material_code "
        szSql &= " where 1 = 1 and a.workshop_id = ?"
        If startTime <> "" Then
            szSql &= "  and a.oper_date >= ?"
        End If
        If endTime <> "" Then
            szSql &= "  and a.oper_date <= ?"
        End If
        If chk = False Then
            szSql &= " and a.finish_count < a.oper_count "
        End If
        szSql &= "  ORDER BY a.oper_date ASC"
        Dim dt As DataTable = DBacs.ExecuteSql(szSql, -1, workshop_id, startTime, endTime)
        Return dt
    End Function

    Public Function updateFinishCount(finish_count As String, id As String) As Integer
        Dim sql As String = String.Empty
        Dim rtn As Integer = 0
        DBacs.BeginTransaction()
        Try
            sql = String.Empty
            sql &= "UPDATE sf.b_pgd_mes SET finish_count = ?, update_time=(SELECT CURRENT_TIMESTAMP(6)) "
            sql &= " WHERE sys_id = ? "
            rtn = DBacs.ExecuteUpdateSql(sql, -1, finish_count, id)
            DBacs.CommitTransaction()
        Catch ex As Exception
            DBacs.RollbackTransaction()
            rtn = -2
        End Try
        Return rtn
    End Function

End Class
